package com.lanlian.cayman.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lanlian.cayman.R;
import com.lanlian.commonlib.bean.ProfitLossInfo;

import java.util.List;

/**
 * <pre>
 *     author : huxiaobo
 *     e-mail : huxiaobo@xlanlian.com
 *     date   : 2018/8/15 16:55
 *     desc   : 止盈止损操作普通
 *     version: 1.0
 * </pre>
 */
public class ProfitLossOrdinaryAdapter extends BaseQuickAdapter<ProfitLossInfo, BaseViewHolder> {

    public ProfitLossOrdinaryAdapter(int layoutResId, @Nullable List<ProfitLossInfo> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ProfitLossInfo item) {
        helper.setBackgroundColor(R.id.lay_position, (helper.getLayoutPosition() + 1) % 2 != 0 ?
                mContext.getResources().getColor(R.color.color_bg_text_view_style2) :
                mContext.getResources().getColor(R.color.color_bg_text_view_style3));
        helper.setText(R.id.tv_profit_price, item.getPriceZy() == null ? "--" : item.getPriceZy().toPlainString());
        helper.setText(R.id.tv_profit_money, item.getStopProfit() == null ? "--" : item.getStopProfit().toPlainString());
        helper.setText(R.id.tv_loss_price, item.getPriceZs() == null ? "--" : item.getPriceZs().toPlainString());
        helper.setText(R.id.tv_loss_money, item.getStopLoss() == null ? "--" : item.getStopLoss().toPlainString());
        helper.setText(R.id.tv_num, item.getNum() + " / ");
        helper.setText(R.id.tv_type, item.getOrderType() == 1 ? "市价" : "限价");
        helper.setText(R.id.tv_profit_weituo_price, item.getLimitPriceZy() == null ? "--" : item.getLimitPriceZy().toPlainString());
        helper.setText(R.id.tv_loss_weituo_price, item.getLimitPriceZs() == null ? "--" : item.getLimitPriceZs().toPlainString());
    }

}
